package com.seanchenxi.gwt.wordpress.xmlrpc.service.model.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

import com.seanchenxi.gwt.wordpress.domain.model.Content;
import com.seanchenxi.gwt.wordpress.domain.model.CustomField;
import com.seanchenxi.gwt.xmlrpc.client.model.impl.BaseModelImpl;


public abstract class ContentImpl extends BaseModelImpl implements Content{
	
	/**
	 * Generated id
	 */
	private static final long serialVersionUID = -5646498850910145929L;
	static final String ID = "page_id";
	static final String[] TITLE = {"title", "page_title"};
	static final String DATE_CREATED = "dateCreated";
	static final String DESCRIPTION = "description";
	static final String USER_ID = "userid";
	static final String LINK = "link";
	static final String PERMA_LINK = "permaLink";
	static final String CATEGORIES = "categories";
	static final String[] EXCERPT = {"mt_excerpt","excerpt"};
	static final String[] TEXT_MORE = {"mt_text_more","text_more"};
	static final String ALLOW_COMMENTS = "mt_allow_comments";
	static final String ALLOW_PINGS = "mt_allow_pings";
	static final String SLUG = "wp_slug";
	static final String PASSWORD = "wp_password";
	static final String AUTHOR = "wp_author";
	static final String AUTHOR_ID = "wp_author_id";
	static final String AUTHOR_DISPLAYNAME = "wp_author_display_name";
	static final String DATE_CREATED_GMT = "date_created_gmt";
	static final String CUSTOM_FIELDS = "custom_fields";
	static final String POST_TYPE = "post_type";
		
	public ContentImpl() {
		super();
	}

	public ContentImpl(HashMap<String, Object> properties) {
		super(properties);
	}

	@Override
	public Date getDateCreated() {
		return get(DATE_CREATED);
	}

	@Override
	public void setDateCreated(Date dateCreated) {
		set(DATE_CREATED, dateCreated);
		
	}

	@Override
	public String getUserId() {
		return get(USER_ID);
	}

	@Override
	public void setUserId(String userid) {
		set(USER_ID, userid);
		
	}

	@Override
	public int getId() {
		return get(ID);
	}

	@Override
	public void setId(int page_id) {
		set(ID, page_id);
		
	}

	@Override
	public String getDescription() {
		return get(DESCRIPTION);
	}

	@Override
	public void setDescription(String description) {
		set(DESCRIPTION, description);
		
	}

	@Override
	public String getTitle() {
		return get(TitleKey());
	}

	@Override
	public void setTitle(String title) {
		set(TitleKey(), title);
		
	}

	@Override
	public String getLink() {
		return get(LINK);
	}

	@Override
	public void setLink(String link) {
		set(LINK, link);
		
	}

	@Override
	public String getPermaLink() {
		return get(PERMA_LINK);
	}

	@Override
	public void setPermaLink(String permaLink) {
		set(PERMA_LINK, permaLink);
		
	}

	@Override
	public ArrayList<String> getCategories() {
		return get(CATEGORIES);
	}

	@Override
	public void setCategories(ArrayList<String> categories) {
		set(CATEGORIES, categories);
		
	}

	@Override
	public String getExcerpt() {
		return get(ExcerptKey());
	}

	@Override
	public void setExcerpt(String excerpt) {
		set(ExcerptKey(), excerpt);
		
	}

	@Override
	public String getTextMore() {
		return get(TextMoreKey());
	}

	@Override
	public void setTextMore(String text_more) {
		set(TextMoreKey(), text_more);
		
	}

	@Override
	public int getAllowComments() {
		return get(ALLOW_COMMENTS);
	}

	@Override
	public void setAllowComments(int mt_allow_comments) {
		set(ALLOW_COMMENTS, mt_allow_comments);
		
	}

	@Override
	public int getAllowPings() {
		return get(ALLOW_PINGS);
	}

	@Override
	public void setAllowPings(int mt_allow_pings) {
		set(ALLOW_PINGS, mt_allow_pings);
		
	}

	@Override
	public String getSlug() {
		return get(SLUG);
	}

	@Override
	public void setSlug(String wp_slug) {
		set(SLUG, wp_slug);
		
	}

	@Override
	public String getPassword() {
		return get(PASSWORD);
	}

	@Override
	public void setPassword(String wp_password) {
		set(PASSWORD, wp_password);
		
	}

	@Override
	public String getAuthorName() {
		return get(AUTHOR);
	}

	@Override
	public void setAuthor(String wp_author) {
		set(AUTHOR, wp_author);
		
	}

	@Override
	public String getAuthorId() {
		return get(AUTHOR_ID);
	}

	@Override
	public void setAuthorId(String wp_author_id) {
		set(AUTHOR_ID, wp_author_id);
		
	}

	@Override
	public String getAuthorDisplayName() {
		return get(AUTHOR_DISPLAYNAME);
	}

	@Override
	public void setAuthorDisplayName(String wp_author_display_name) {
		set(AUTHOR_DISPLAYNAME, wp_author_display_name);
		
	}

	@Override
	public Date getDateCreatedGMT() {
		return get(DATE_CREATED_GMT);
	}

	@Override
	public void setDateCreatedGMT(Date date_created_gmt) {
		set(DATE_CREATED_GMT, date_created_gmt);
		
	}

	@Override
	public ArrayList<CustomField> getCustomFields() {
		return get(CUSTOM_FIELDS);
	}

	@Override
	public void setCustomFields(ArrayList<CustomField> custom_fields) {
		set(CUSTOM_FIELDS, custom_fields);
		
	}
	
	@Override
	public ArrayList<String> getKeyWords() {
		return get("mt_keywords");
	}

	@Override
	public void setKeyWords(ArrayList<String> keyWords) {
		set("mt_keywords", keyWords);
		
	}

	@Override
	public ArrayList<String> getPingBackUrls() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setPingBackUrls(ArrayList<String> urls) {
		// TODO Auto-generated method stub
		
	}
	
	protected String TitleKey(){
		for(String titleKey : TITLE){
			if(getPropertyNames().contains(titleKey)){
				return titleKey;
			}
		}
		return TITLE[0];
	}
	
	protected String ExcerptKey(){
		for(String excerptKey : EXCERPT){
			if(getPropertyNames().contains(excerptKey)){
				return excerptKey;
			}
		}
		return EXCERPT[0];	
	}
	
	protected String TextMoreKey(){
		for(String textMoreKey : TEXT_MORE){
			if(getPropertyNames().contains(textMoreKey)){
				return textMoreKey;
			}
		}
		return TEXT_MORE[0];	
	}
	

}
